﻿using System;
using System.Collections.Generic;
using UM_SERVER.Packet;

namespace UM_SERVER
{
    /// <summary>
    ///     网络信息池事件类
    /// </summary>
    class NetworkMessagePoolEvent
    {
        public NetworkMessagePoolEvent()
        {
            Globle.NetworkMessagePool.OnInsertedData += NetworkMessagePool_OnInsertedData;
        }

        void NetworkMessagePool_OnInsertedData(object sender, UMFramework.Network.Network_MessagePool.OnInsertedDataEventArgs e)
        {
            Dictionary<String,byte[]> Order = e.MessagePool.GetXmlProtocolData();
            if (Order!= null)
            {
                //创建解析器指针
                IParser TempParser;
                //获取解析器
                if ((TempParser = (PackageHelper.FindParser(PackageHelper.GetProtocol(Order)))) != null)
                {
                    //解析出收包
                    Globle.processorRouter.PacketArrived(TempParser.ParserInPackage(Order));
                }
            }
        }
    }
}
